<div class="container">
  <div class="page-header">
    <h2>Add Comment</h2>
  </div>

  <div>
    <div id="notice"></div>
    <br/>

    <%= form_tag "/comments/add/", :remote => true, :id => 'add_comment_form', :role => "form" do %>
        <div class="form-group">
          <label for="comment">Comment</label>

          <textarea id="comment" name="comment" class="form-control" rows="3"></textarea>

          <br/>
          <%= submit_tag "Add Comment", :disable_with => "Please wait...", :class => "btn btn-primary" %>

          <input type="hidden" name="content_id" value="<%= @published_content.content.id %>"/>

        </div>
    <% end %>

  </div>
</div>

<script type="text/javascript">
    jQuery('#add_comment_form').bind('ajax:success', function (e, response) {
        var html = '';

        if (response.success) {
            html = [
                '<div class="alert alert-success" >',
                '<button type="button" class="close" data-dismiss="alert">&times;</button>',
                response.message,
                '</div>'
            ].join('');
        }
        else {
            html = [
                '<div class="alert alert-danger" >',
                '<button type="button" class="close" data-dismiss="alert">&times;</button>',
                response.message,
                '</div>'
            ].join('');
        }

        jQuery('#notice').html(html);
    });
</script>